package org.codeart.driver.controller;

import org.codeart.common.dto.DriverUserWorkStatus;
import org.codeart.common.util.R;
import org.codeart.driver.service.DriverUserWorkStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DriverUserWorkStatusController {

    @Autowired
    private DriverUserWorkStatusService driverUserWorkStatusService;

    @PutMapping("/driver-user-work-status")
    public R<Void> changeWorkStatus(@RequestBody DriverUserWorkStatus driverUserWorkStatus) {
        Long driverId = driverUserWorkStatus.getDriverId();
        Integer status = driverUserWorkStatus.getWorkStatus();
        boolean b = driverUserWorkStatusService.changeWorkStatus(driverId, status);
        if (b) {
            return R.ok();
        }
        return R.fail();
    }

    @GetMapping("/work-status")
    public R<DriverUserWorkStatus> getWorkStatus(Long driverId) {
        return driverUserWorkStatusService.getWorkStatus(driverId);
    }


}
